package RandVars;

public class ExpRandVar extends RandVar {
	// int seed;
	Rng random;
	double lambda;
	
	public ExpRandVar(double mean) {
		super(mean);
		random = new Rng();
		lambda = (1 / mean);
	}

	public ExpRandVar(double mean, Rng rng) {
		super(mean);
		random = rng;
		lambda = (1 / mean);
	}


	public long getLongRV() {
		double d;
		do{
		 d = random.nextDouble();
		}while (d==0.0);

		// we need to use round() because casting double to long will always
		// round to zero
		long rv = Math.round((-1 * Math.log(d)) / lambda);
		return rv;
	}
	
	public double getDoubleRV(){
		double d;
		do{
		 d = random.nextDouble();
		}while (d==0.0);
		return (-1 * Math.log(d)) / lambda;
	}
}
